package de.tu_darmstadt.gdi1.battleship.model;

import java.io.File;

import de.tu_darmstadt.gdi1.battleship.controller.NetworkClientInteraction;
import de.tu_darmstadt.gdi1.battleship.controller.NetworkServerInteraction;
import de.tu_darmstadt.gdi1.battleship.controller.UserInteraction;
import de.tu_darmstadt.gdi1.battleship.exceptions.BoatFailException;
import de.tu_darmstadt.gdi1.battleship.exceptions.InternalFailureException;
import de.tu_darmstadt.gdi1.battleship.exceptions.InvalidCoordinatesException;
import de.tu_darmstadt.gdi1.battleship.exceptions.NumberFailException;
import de.tu_darmstadt.gdi1.battleship.exceptions.ParameterOutOfRangeException;
import de.tu_darmstadt.gdi1.battleship.view.StudentWindow;

public class Main {

	/**
	 * @param args
	 * @throws NumberFailException
	 * @throws BoatFailException
	 * @throws InvalidCoordinatesException
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		File f = new File(
				"src/de/tu_darmstadt/gdi1/resources/levels/defaultlevels/01.lvl");
		System.out.println("Level to load: " + f.getAbsolutePath());

		BattleshipGame bsg;
		try {
			bsg = new BattleshipGame(f);
			System.out.println("Level loaded.");
		} catch (Exception e1) {
			System.err
					.println("Could not read Level from File. Generates random map.");
			bsg = new BattleshipGame();
		}

		StudentWindow mainWnd;
		try {
			mainWnd = new StudentWindow("* B a t t l e s h i p *", bsg);
//			UserInteraction ctrl;
//			ctrl = new UserInteraction(bsg, mainWnd);
//			mainWnd.setMainCtrl(ctrl);

			mainWnd.setResizable(true);
			mainWnd.getGamePanel().setAutosize(true);
			// mainWnd.setSize(400, 100);
			mainWnd.setVisible(true);

			mainWnd.notifyLevelLoaded(21, 10);
		} catch (InternalFailureException e) {
			System.err.println("Some error stopped Window to redraw");
		} catch (ParameterOutOfRangeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
